﻿import QtQuick 2.0

Item {
    id: root
    width: 228
    height: 229

    Component.onCompleted: {
        timer.restart()
    }

    Timer{
        id: timer
        triggeredOnStart: true
        interval: 500
        repeat: true
        onTriggered: {
            run()
        }
    }

    function run(){
        var date = new Date
        var hour = date.getHours()
        var minute = date.getMinutes()
        var sec = date.getSeconds()

        rhour.angle = hour * 30 + minute / 60 * 30
        rminute.angle = minute * 6
        rsec.angle = sec * 6

//        console.log(hour,minute,rhour.angle,rminute.angle)
    }

    Image {
        id: imgbg
        source: "qrc:/image/bg2.png"
    }

    Image {
        id: imgdot
        x: parent.width/2 - 8
        y: parent.height/2 - 5
        source: "qrc:/image/dot.png"
    }

    Image {
        id: imgminute
        x: imgdot.x + imgdot.width/2 - width/2
        y: imgdot.y + imgdot.height/2 - height
        source: "qrc:/image/minutebar.png"

        transform: Rotation{
            id: rminute
            origin.x: imgminute.width/2
            origin.y: imgminute.height
            axis.x: 0
            axis.y: 0
            axis.z: 1
            angle: 0
        }
    }

    Image {
        id: imghour
        x: imgdot.x + imgdot.width/2 - width/2
        y: imgdot.y + imgdot.height/2 - height
        source: "qrc:/image/hourbar.png"

        transform: Rotation{
            id: rhour
            origin.x: imghour.width/2
            origin.y: imghour.height
            axis.x: 0
            axis.y: 0
            axis.z: 1
            angle: 0
        }
    }

    Image {
        id: imgsec
        x: imgdot.x + imgdot.width/2 - width/2
        y: imgdot.y + imgdot.height/2 - height
        source: "qrc:/image/sebar.png"

        transform: Rotation{
            id: rsec
            origin.x: imgsec.width/2
            origin.y: imgsec.height
            axis.x: 0
            axis.y: 0
            axis.z: 1
            angle: 0
        }
    }
}
